package com.example.hyw.szysteam.myEmail;

import android.util.Log;

import java.io.File;
/**
 * Created by HYW on 2018/5/19.
 */

public class SendMailUtil {

    private static final String HOST = "smtp.163.com";
    private static final String PORT = "465"; //或者465  994
    private static final String FROM_ADD = "szysteam@163.com";
    private static final String FROM_PSW = "hyw970524";
    private static final String TO_ADD = "826664258@qq.com";

    public static void send(String toAdd,String content){
        final MailInfo mailInfo = creatMail(toAdd,content);
        final MailSender sms = new MailSender();
        new Thread(new Runnable() {
            @Override
            public void run() {
                sms.sendTextMail(mailInfo);

            }
        }).start();
    }

    private static MailInfo creatMail(String toAdd,String content) {
        final MailInfo mailInfo = new MailInfo();
        mailInfo.setMailServerHost(HOST);
        mailInfo.setMailServerPort(PORT);
        mailInfo.setValidate(true);
        mailInfo.setUserName(FROM_ADD); // 你的邮箱地址
        mailInfo.setPassword(FROM_PSW);// 您的邮箱密码
        mailInfo.setFromAddress(FROM_ADD); // 发送的邮箱
        mailInfo.setToAddress(toAdd); // 发到哪个邮件去
        mailInfo.setSubject("四则运算团队"); // 邮件主题
        mailInfo.setContent(content); // 邮件文本
        return mailInfo;
    }
}
